Move generated gitweb_config.perl to hidden tmp directory Since some systems have a /tmp autocleaner, we don't want to trust our gitweb configuration file to stay there. Instead keep it with the extracted WARs inside of our own private temporary location. Change-Id: I5f4dea46a755bf3296f15ae38361452fe8df6655 Signed-off-by: Shawn O. Pearce <sop@google.com>
diff --git a/gerrit-httpd/pom.xml b/gerrit-httpd/pom.xml index 07026c9..39b2788 100644 --- a/gerrit-httpd/pom.xml +++ b/gerrit-httpd/pom.xml
@@ -76,6 +76,12 @@ <dependency> <groupId>com.google.gerrit</groupId> + <artifactId>gerrit-launcher</artifactId> + <version>${project.version}</version> + </dependency> + + <dependency> + <groupId>com.google.gerrit</groupId> <artifactId>gerrit-server</artifactId> <version>${project.version}</version> </dependency> diff --git a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/gitweb/GitWebServlet.java b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/gitweb/GitWebServlet.java index 3a1f2b62..04f85a7 100644 --- a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/gitweb/GitWebServlet.java +++ b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/gitweb/GitWebServlet.java
@@ -31,6 +31,7 @@ import com.google.gerrit.common.data.GerritConfig; import com.google.gerrit.httpd.GitWebConfig; +import com.google.gerrit.launcher.GerritLauncher; import com.google.gerrit.reviewdb.Project; import com.google.gerrit.server.IdentifiedUser; import com.google.gerrit.server.config.SitePaths; @@ -117,7 +118,7 @@ private void makeSiteConfig(final SitePaths site, final GerritConfig gerritConfig) throws IOException { - final File myconf = File.createTempFile("gitweb_config_", ".perl"); + final File myconf = GerritLauncher.createTempFile("gitweb_config", ".perl"); // To make our configuration file only readable or writable by us; // this reduces the chances of someone tampering with the file. @@ -128,7 +129,6 @@ myconf.setWritable(true, true /* owner only */); myconf.setReadable(true, true /* owner only */); - myconf.deleteOnExit(); _env.set("GIT_DIR", "."); _env.set("GITWEB_CONFIG", myconf.getAbsolutePath());